<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Javascript任务二</title>
  </head>
<body>

  <h3>污染城市列表</h3>
  <ul id="aqi-list">

  </ul>

<script type="text/javascript">

var aqiData = [
  ["北京", 90],
  ["上海", 50],
  ["福州", 10],
  ["广州", 50],
  ["成都", 90],
  ["西安", 100]
];

/*
 * 遍历读取aqiData中各个城市的数据
 * 将空气质量指数大于60的城市显示到aqi-list的列表中
 */
(function () {
  for(var i = 0; i<aqiData.length; i++){
    if(aqiData[1][i] <= 60){
	  aqiData.splice( i,1 );
	  i--;
	}
  }
  aqiData.sort( function(a,b) {return b[1]-a[1];} );
  for(var i=0; i<aqiData.length;i++){
    var change = ["一","二","三"];
    var liNode = document.createElement( "li" );
    var textNode = document.createTextNode("第" +change[i]+ "名：" +aqiData[i][0]+ "," +aqiData[i][1]);
    liNode.appendChild( textNode );
    document.getElementById( "aqi-list" ).appendChild( liNode );
  }
})();

</script>
</body>
</html>